/*
 * Copyright:  2018 smarabbit studio.
 *
 *  Licensed under the Confluent Community License; you may not use this file
 *  except in compliance with the License.  You may obtain a copy of the License at
 *
 *  http://www.confluent.io/confluent-community-license
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *  WARRANTIES OF ANY KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations under the License.
 *
 *  @作   者： 黄开晖 (117227773@qq.com)
 *  @日   期:  2021年6月1日
 */
package com.massyframework.beanskin.runtime.modular.plugin;

import java.util.List;
import java.util.Set;
import java.util.function.Consumer;

import com.massyframework.beanskin.ModuleIdentifier;
import com.massyframework.beanskin.ModuleRepository;
import com.massyframework.beanskin.RequireLibraryDescriptor;
import com.massyframework.beanskin.plugin.Plugin;
import com.massyframework.beanskin.plugin.PluginBuilder;
import com.massyframework.beanskin.runtime.modular.InitParamsBuilder;
import com.massyframework.beanskin.service.ServiceRepositoryFactory;
import com.massyframework.beanskin.util.classloading.ModuleClassLoader;

/**
 * 缺省的插件构建器
 * @author huangkh
 *
 */
public final class DefaultPluginBuilder extends InitParamsBuilder implements PluginBuilder {

	protected String activatorClassName;
	
	/**
	 * 
	 */
	public DefaultPluginBuilder() {
		
	}

	@Override
	public DefaultPluginBuilder addRequireLibrary(RequireLibraryDescriptor value) {
		super.addRequireLibrary(value);
		return this;
	}
	
	@Override
	public DefaultPluginBuilder addTags(Set<String> value) {
		super.addTags(value);
		return this;
	}

	@Override
	public DefaultPluginBuilder activatorClassName(String value) {
		this.activatorClassName = value;
		return this;
	}
	
	@Override
	public DefaultPluginBuilder decryption(String publicKey, String x509Name, String x509Encrypted,
			List<String> classNames, List<String> scriptFileNames) {
		super.decryption(publicKey, x509Name, x509Encrypted, classNames, scriptFileNames);
		return this;
	}

	@Override
	public DefaultPluginBuilder developer(String shortName, String name, String homePage) {
		super.developer(shortName, name, homePage);
		return this;
	}

	@Override
	public String getActivatorClassName() {
		return this.activatorClassName;
	}

	

	@Override
	public DefaultPluginBuilder setParameter(String name, String value) {
		super.setParameter(name, value);
		return this;
	}

	@Override
	public DefaultPluginBuilder setParameter(String name, String value, Consumer<Boolean> action) {
		super.setParameter(name, value, action);
		return this;
	}

	@Override
	public DefaultPluginBuilder identifier(ModuleIdentifier value) {
		super.identifier(value);
		return this;
	}

	@Override
	public DefaultPluginBuilder name(String value) {
		super.name(value);
		return this;
	}

	@Override
	public DefaultPluginBuilder description(String value) {
		super.description(value);
		return this;
	}

	@Override
	public DefaultPluginBuilder moduleRepository(ModuleRepository value) {
		super.moduleRepository(value);
		return this;
	}

	@Override
	public DefaultPluginBuilder classLoader(ModuleClassLoader value) {
		super.classLoader(value);
		return this;
	}

	@Override
	public DefaultPluginBuilder serviceRepositoryFactory(ServiceRepositoryFactory value) {
		super.serviceRepositoryFactory(value);
		return this;
	}

	@Override
	public Plugin build() {
		DefaultPlugin result = new DefaultPlugin(this);
		result.init();
		return result;
	}

}
